package com.geodroid.common.kernel;



public class Kernel {
	
	protected Construction cons;
	
	/** standard precision */
	public final static double STANDARD_PRECISION = 1E-8;
	
	/** current working precision */
	public static double EPSILON = STANDARD_PRECISION;
	
	
	/** minimum precision */
	public final static double MIN_PRECISION = 1E-5;
	private final static double INV_MIN_PRECISION = 1E5;
	
	/** is abs(x) < epsilon ? */
	final public static boolean isZero(double x) {
		return (-EPSILON < x) && (x < EPSILON);
	}
	
	/**
	 * Returns whether x is equal to y infinity == infinity returns true eg 1/0
	 * -infinity == infinity returns false eg -1/0 -infinity == -infinity
	 * returns true undefined == undefined returns false eg 0/0
	 */
	final public static boolean isEqual(double x, double y) {
		if (x == y) {
			return true;
		}
		return ((x - EPSILON) <= y) && (y <= (x + EPSILON));
	}
	
	final public static boolean isEqual(double x, double y, double eps) {
		if (x == y) {
			return true;
		}
		return ((x - eps) < y) && (y < (x + eps));
	}
	
	
}
